//
//  SearchViewController.m
//  NewMyMusicAPP
//
//  Created by 08- 张志强 on 15/6/25.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SearchViewController.h"

@interface SearchViewController ()

@end

@implementation SearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor=[UIColor blackColor];
    
 
    
    self.searchV=[[[SearchView alloc]initWithFrame:[[UIScreen mainScreen]bounds]]autorelease];
    
    //返回按钮
    UIImage *image2=[UIImage imageNamed:@"VList_Left@2x.png"];
    image2=[image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:image2 style:UIBarButtonItemStylePlain target:self action:@selector(PopButton)];
    
    
    
    //搜索
    UIImage *image3 = [UIImage imageNamed:@"Search@3x.png"];
    image3 = [image3 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:image3 style:UIBarButtonItemStylePlain target:self action:@selector(barButton)]autorelease];
    
    
    
    
    [self.view addSubview:self.searchV];
    
    NSMutableArray *array = [NSMutableArray arrayWithObjects:@"周杰伦",@"陈奕迅",@"张杰",@"邓紫棋",@"林俊杰",@"张靓颖",@"张学友",@"李荣浩",@"王力宏",@"徐良",@"姚贝娜",@"冷漠",@"五月天",@"胡彦斌",@"刘德华",@"张宇",@"张惠妹",@"羽泉",@"杨坤",@"李易峰",@"陶喆",@"任贤齐",@"蔡依林",@"邓超",@"EXO",@"张国荣", nil];
    self.cloud = [[[CloudView alloc]initWithFrame:CGRectMake(0,HEIGHT * 75,WIDTH * 375,HEIGHT * 527)andNodeCount:array]autorelease];
    self.cloud.delegate = self;
    [self.view addSubview:self.cloud];
    
    //点空白处收回键盘
    self.view.userInteractionEnabled=YES;
    UITapGestureRecognizer *singleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(fingerTapped:)];
    
    [self.view addGestureRecognizer:singleTap];
    

    
}
-(void)fingerTapped:(UITapGestureRecognizer *)gestureRecognizer
{
    [self.view endEditing:YES];
    
}



//点文字按钮
-(void)didSelectedNodeButton:(CloudButton *)button
{
    
    SearchDataViewController *searchDataV=[[SearchDataViewController alloc]init];
    searchDataV.title=button.titleLabel.text;
    
   // NSLog(@"buttonTitle = %@",button.titleLabel.text);
    [self.navigationController pushViewController:searchDataV animated:YES];
    
}
//点搜索
-(void)barButton
{
  
    
    
    SearchDataViewController *searchDataV=[[SearchDataViewController alloc]init];
    if (self.searchV.textField.text.length == 0) {
        
        UIAlertView *alerV=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入内容" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alerV show];
        
    }
    else
        
    {
        searchDataV.title = self.searchV.textField.text;
       // NSLog(@"searchV.textField.text===========%@",self.searchV.textField.text);
        [self.navigationController pushViewController:searchDataV animated:YES];
    }
    [self.searchV.textField resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)PopButton
{
    
    [self.navigationController popViewControllerAnimated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
